const getters = {
  // 获取侧边栏状态
  sidebar: state => {
    if (!state || !state.app || !state.app.sidebar) {
      return undefined
    }
    return state.app.sidebar
  },

  // 获取设备信息
  device: state => {
    if (!state || !state.app || !state.app.device) {
      return undefined
    }
    return state.app.device
  },

  // 获取用户令牌
  token: state => {
    if (!state || !state.user || !state.user.token) {
      return undefined
    }
    return state.user.token
  },

  // 获取用户头像
  avatar: state => {
    if (!state || !state.user || !state.user.avatar) {
      return undefined
    }
    return state.user.avatar
  },

  // 获取用户名
  name: state => {
    if (!state || !state.user || !state.user.name) {
      return undefined
    }
    return state.user.name
  },

  // 获取用户角色
  roles: state => {
    if (!state || !state.user || !state.user.roles) {
      return undefined
    }
    return state.user.roles
  },

  // 获取权限路由
  permission_routes: state => {
    if (!state || !state.permission || !state.permission.routes) {
      return undefined
    }
    return state.permission.routes
  },

  // 获取已访问视图
  visitedViews: state => {
    if (!state || !state.tagsView || !state.tagsView.visitedViews) {
      return undefined
    }
    return state.tagsView.visitedViews
  },

  // 获取缓存视图
  cachedViews: state => {
    if (!state || !state.tagsView || !state.tagsView.cachedViews) {
      return undefined
    }
    return state.tagsView.cachedViews
  }
}

export default getters
